package com.zhouu.example.member.mobile.controller;

import com.zhouu.example.core.controller.BaseController;
import com.zhouu.example.core.message.Result;
import com.zhouu.example.member.mobile.service.MobileMemberInfoService;
import com.zhouu.example.member.mobile.vo.request.MemberInfoRegisterRequest;
import com.zhouu.example.member.mobile.vo.response.MemberInfoDetailResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 会员信息
 *
 * @author zhouu
 * @date 2021-02-23 22:14
 */
@RestController
@RequestMapping("memberInfo")
public class MemberInfoController extends BaseController {

    private final MobileMemberInfoService mobileMemberInfoService;

    /**
     * 查看会员详细资料
     *
     * @return Result<MemberInfoDetailResponse>
     */
    @RequestMapping(value = "detail", method = RequestMethod.GET)
    public Result<MemberInfoDetailResponse> detail() {
        String memberId = "001";
        MemberInfoDetailResponse response = mobileMemberInfoService.detail(memberId);
        return getSuccessResult(response);
    }

    /**
     * 会员注册
     *
     * @param memberInfoRegisterRequest 注册信息
     * @return Result
     */
    @RequestMapping(value = "register", method = RequestMethod.POST)
    public Result register(MemberInfoRegisterRequest memberInfoRegisterRequest) {
        mobileMemberInfoService.register(memberInfoRegisterRequest);
        return getSuccessResult(null);
    }

    @Autowired
    public MemberInfoController(MobileMemberInfoService mobileMemberInfoService) {
        this.mobileMemberInfoService = mobileMemberInfoService;
    }
}
